// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import FSMState from "./FSMState";

const {ccclass, property} = cc._decorator;

export default class FSMManager {

    // 状态列表
    stateList: FSMState[] = [];

    // 当前状态
    currentState: number = -1;

    // 改变状态
    changeState(stateId: number) {
        this.currentState = stateId;
        // 调用新状态的enter方法
        this.stateList[this.currentState].onEnter();
    }

    // 状态更新中
    onUpdate(dt) {
        if (this.currentState != -1) {
            this.stateList[this.currentState].onUpdate(dt);
        }
    }
}
